cmake_minimum_required(VERSION 3.5)
project(robot_server_pc)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX})

# FIND QT
find_package(Qt6 COMPONENTS Core Network Gui REQUIRED) #Ejemplo para QWidget


include_directories(../common/robot_server)
include_directories(../common/jsonutils  ../common/Eigen340/include  ../common/wyfuns)
include_directories(include/robot_server_pc)


# find ROs2 dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(pccmd_msg REQUIRED)
find_package(param_msg REQUIRED)
find_package(clawcmd_msg REQUIRED)
find_package(rsswitch_msg REQUIRED)
find_package(slamready_msg REQUIRED)
find_package(slampos_msg REQUIRED)
find_package(rspos_msg REQUIRED)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

file(GLOB_RECURSE MOC_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS
  include/robot_server_pc/*.h *.hpp
  ../common/robot_server/*.h 
  )

QT6_WRAP_CPP(QT_HEADERS ${MOC_HEADERS})


include_directories(
  ${rclcpp_INCLUDE_DIRS}
  )

file(GLOB SOURCE_FILES
  "src/*.cpp"
  )

file(GLOB COMMON_FILES
  "../common/robot_server/*.cpp"
  "../common/jsonutils/*.cpp"
  "../common/wyfuns/*.cpp"
  )

#file(GLOB JSON_FILES
#  "../common/jsonutils/*.cpp"
#  )

add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${COMMON_FILES}  ${QT_HEADERS})

ament_target_dependencies(${PROJECT_NAME}
  rclcpp
  pccmd_msg
  param_msg
  clawcmd_msg
  rsswitch_msg
  slamready_msg
  slampos_msg
  rspos_msg
  )

target_link_libraries(${PROJECT_NAME}
  Qt6::Core
  Qt6::Network
  Qt6::Gui
  )

install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})


ament_package()
